from pygame_test.Sector import Sector
import pygame


# 扇形的旋转和移动
def main():
    winx = 300
    winy = 300
    pygame.init()
    screen = pygame.display.set_mode((winx, winy))
    x = 80
    y = 80
    r = 50
    b =mouse1= 315 # 上嘴唇张开角度
    e =mouse2= 225 # 下嘴唇张开角度
    mouse0 = 270 # 嘴闭合的角度
    open_speed = 3
    speedx = 1
    speedy = 1
    mouse_open = False
    sector = Sector(x, y, r, (255, 255, 255), b, e)
    fclock = pygame.time.Clock()
    while True:
        x+=speedx
        y+=speedy

        # spin
        b += 1
        e +=1
        mouse0+=1
        mouse1+=1

        sector = Sector(x, y, r, (255, 255, 255), b, e)
        if b >= mouse1:
            mouse_open = False
        elif b <= mouse0:
            mouse_open = True
        if mouse_open:
            b += open_speed
            e -= open_speed
        else:
            b -= open_speed
            e += open_speed

        print(sector.x,sector.y)
        screen.fill((0, 0, 0))
        sector.draw(screen)
        pygame.display.update()
        fclock.tick(40)


if __name__ == '__main__':
    main()
